<?php

namespace app\controllers;

use app\logic\DepartmentLogic;
use yii\web\HttpException;
use app\components\Controller;
use app\forms\department\InfoForm;
use app\forms\department\ParamForm;
use app\forms\department\DeleteForm;

/**
 * 部门控制器
 */
class DepartmentController extends Controller
{
    protected function verbs()
    {
        return [
            'create' => ['POST'],
            'update' => ['POST'],
            'delete' => ['POST'],
            'get-info' => ['GET'],
            'get-drop-list' => ['GET']
        ];
    }

    /**
     * 创建 部门
     * @throws HttpException
     */
    public function actionCreate()
    {
        return DepartmentLogic::create(getParams());
    }

    /**
     * 编辑 部门
     * @throws HttpException
     */
    public function actionUpdate()
    {
        return DepartmentLogic::update(getParams());
    }

    /**
     * 删除 部门
     * @throws HttpException
     * @throws \Throwable
     */
    public function actionDelete()
    {
        return DepartmentLogic::delete(getParams());
    }

    /**
     * 部门 下拉列表 （ 部门、岗位 添加&编辑 用 ）
     * @return array
     * @throws HttpException
     */
    public function actionGetDropList()
    {
        return DepartmentLogic::getDropList(getParams());
    }

    /**
     * 部门 编辑时的信息
     * @return array
     * @throws HttpException
     */
    public function actionGetInfo()
    {
        return DepartmentLogic::getInfo(getParams());
    }
}
